<template>
  <div class="feedback-detail full-box shadow-box padding-box">
    <div class="operate-bar">
      <div class="btn-group">
        <el-button type="info" size="default" @click="goBack">返回</el-button>
      </div>
    </div>
    <el-collapse v-if="info" v-model="activeNames" :accordion="false">
      <el-collapse-item title="项目信息" :name="1">
        <div class="desc">
          <label>项目名称：</label>
          <span>{{ info.project_name }}</span>
        </div>
        <div class="desc">
          <label>开工日期：</label>
          <span>{{ info.fact_start_date }}</span>
        </div>
      </el-collapse-item>
      <el-collapse-item title="问题信息" :name="2">
        <div class="desc">
          <label>问题来源：</label>
          <span>{{ info.source_type }}</span>
        </div>
        <div class="desc">
          <label>存在问题：</label>
          <span>{{ info.problem_desc }}</span>
        </div>
        <div class="desc">
          <label>工作建议：</label>
          <span>{{ info.proposal }}</span>
        </div>
        <div class="desc">
          <label>协调情况：</label>
          <span>{{ info.concert_content }}</span>
        </div>
        <div class="desc">
          <label>建议承办单位：</label>
          <span>{{ info.proposeDept }}</span>
        </div>
        <div class="desc">
          <label>期望问题解决期限：</label>
          <span>{{ info.finish_limit_date }}</span>
        </div>
        <div class="desc">
          <label>是否已与承办单位协调：</label>
          <span>{{ info.concert_fag }}</span>
        </div>
      </el-collapse-item>
      <el-collapse-item
        v-if="info.assignList != undefined"
        title="交办信息"
        :name="3"
      >
        <div class="desc">
          <label> 问题来源： </label>
          <span>
            {{ info.assignList.source_type }}
          </span>
        </div>
        <div class="desc">
          <label> 问题描述： </label>
          <span>
            {{ info.assignList.problem_desc }}
          </span>
        </div>
        <div class="desc">
          <label> 交办意见： </label>
          <span>
            {{ info.assignList.assign_opinion }}
          </span>
        </div>
        <div class="desc">
          <label> 交办人： </label>
          <span>
            {{ info.assignList.assigner_name }}
          </span>
        </div>
        <div class="desc">
          <label> 交办日期： </label>
          <span>
            {{ info.assignList.assign_date }}
          </span>
        </div>
      </el-collapse-item>
      <el-collapse-item
        v-if="info.assignList != undefined"
        title="反馈信息"
        :name="4"
      >
        <!-- 反馈表单 -->
        <template v-if="[0, 2].indexOf(parseInt(info.assignList.status)) > -1">
          <el-form
            :model="form"
            ref="form"
            :rules="rules"
            label-width="100px"
            :inline="false"
          >
            <el-form-item
              label-width="200px"
              label="是否与建设单位协调一致："
              prop="mend_unanimous"
            >
              <el-select
                style="width: 100px"
                v-model="form.mend_unanimous"
                value-key=""
                placeholder=""
              >
                <el-option :key="0" label="是" value="是"></el-option>
                <el-option :key="1" label="否" value="否"></el-option>
              </el-select>
            </el-form-item>

            <el-form-item label="整改反馈：" prop="mend_feedback">
              <el-input
                type="textarea"
                v-model="form.mend_feedback"
                placeholder="请输入整改反馈结果"
                :autosize="{
                  minRows: 5,
                  maxRows: 10,
                }"
              ></el-input>
            </el-form-item>

            <el-form-item label="反馈日期：" prop="">
              <el-date-picker
                v-model="currentDate"
                type="date"
                format="yyyy-MM-dd"
                value-format="yyyy-MM-dd"
                placeholder=""
                disabled
              >
              </el-date-picker>
            </el-form-item>
            <el-form-item label="">
              <el-button type="primary" @click="handleSave">反馈</el-button>
            </el-form-item>
          </el-form>
        </template>
        <!-- 反馈单 -->
        <template v-if="info.assignList.mendList != undefined">
          <el-tabs
            v-model="activeFeedBack"
            type="border-card"
            tab-position="top"
          >
            <el-tab-pane
              v-for="(feedback, index) in info.assignList.mendList"
              :key="'fb_' + index"
              :label="`第 ${info.assignList.mendList.length - index} 次反馈`"
              :name="index + ''"
            >
              <div>
                <div class="desc">
                  <label> 反馈结果： </label>
                  <span>
                    {{ feedback.mend_feedback }}
                  </span>
                </div>
                <div class="desc">
                  <label> 是否已与建设单位协调一致： </label>
                  <span>
                    {{ feedback.mend_unanimous }}
                  </span>
                </div>
                <div class="desc">
                  <label> 反馈日期： </label>
                  <span>
                    {{ feedback.mend_time }}
                  </span>
                </div>
              </div>
              <el-divider></el-divider>
              <div>
                <div class="desc">
                  <label> 评价结果： </label>
                  <span>
                    {{ feedback.check_status == 0 ? "满意" : "不满意" }}
                  </span>
                </div>
                <div class="desc">
                  <label> 评价内容： </label>
                  <span>
                    {{ feedback.check_opinion }}
                  </span>
                </div>
                <div class="desc">
                  <label> 评价时间： </label>
                  <span>
                    {{ feedback.check_time }}
                  </span>
                </div>
              </div>
            </el-tab-pane>
          </el-tabs>
        </template>
      </el-collapse-item>
    </el-collapse>
  </div>
</template>

<script>
import { required } from "@/utils/eValidate";
import {
  getAssignDetails,
  postAssignFeedback,
} from "@/api/MajorProjectPromotion/Index";
export default {
  name: "QuestionFeedbackDetails",
  data() {
    return {
      id: 0,
      info: null,
      activeNames: [3, 4],
      // 激活反馈单
      activeFeedBack: "",
      form: {
        mend_feedback: "",
        mend_unanimous: "",
        mend_time: "",
      },
      currentDate: new Date(),
      rules: {
        mend_feedback: [required],
        mend_unanimous: [required],
      },
    };
  },
  methods: {
    initData() {
      getAssignDetails({
        id: this.id,
      }).then((res) => {
        if (res.code == 0) {
          this.info = res.data;
        }
      });
    },
    handleSave() {
      this.$refs.form.validate().then((valid) => {
        this.form.assign_id = this.id;

        postAssignFeedback(this.form).then((res) => {
          if (res.code == 0) {
            this.$message.success("反馈成功");
            this.initData();
          }
        });
      });
    },
    goBack() {
      this.$router.push("/majorProjectPromotionQuestionFeedback");
    },
  },
  created() {
    this.id = this.$route.params.id;
    this.initData();
  },
};
</script>

<style lang="scss" scoped>
</style>